<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    </head>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        textarea{
            width: 800px;
            height: 200px;
            resize: none;
            margin: 0 auto;
            display: block;
            outline: none;
            font-size: 25px;
            font-weight: 600;
        }
        textarea:hover{
            border: 1px solid #f60;
        }
        button{
            width: 800px;
            height: 30px;
            margin: 20px auto;
            display: block;
            outline: none;
            cursor: pointer;
            color: white;
            background: #f60;
            border: none;
        }
        button:hover{
            background: #f75;
        }
        ul{
            margin: 0 auto;
            width: 800px;
        }
        ul li{
            border: 1px solid rgb(32, 166, 255);
            margin: 40px auto;
            font-size: 25px;
            font-weight: 600;
            padding: 20px;
            position: relative;
        }
        ul li p{
            color: rgb(206, 206, 206);
            font-size: 15px;
            
        }
        ul li i{
            position: absolute;
            right: -10px;
            top: -20px;
            cursor: pointer;

        }
        ul li i:hover{
            color: #f60;
        }
    </style>
    <body>
        <textarea name="" id="" cols="30" rows="10" maxlength="50"></textarea>
        <button>发送</button>
        <ul>
            <li>
                C语言
                <p class="date">日期：2021-6-1 00:00:00</p>
                <i class="del">X</i>
            </li>
            <li>
                C++
                <p class="date">日期：2021-6-1 00:00:00</p>
                <i class="del">X</i>
            </li>
        </ul>
    </body>
    <script>
        $(function(){
            bind()
        })
        $('button').click(function(){
            var year=new Date().getFullYear()
            var month=new Date().getMonth()+1
            var day=new Date().getDate()
            var h=new Date().getHours()
            var m=new Date().getMinutes()
            var s=new Date().getSeconds()
            var textVal=$('textarea').val()
            if(textVal==null||textVal==''){
                alert('文字不能为空')
                return;
            }
            $('ul').append('<li>'+textVal+'<p class="date">日期：'+year+'-'+month+'-'+day+'  '+h+':'+m+':'+s+'</p><i class="del">X</i></li>')
            $('textarea').val('')
            bind()
        })
        function bind(){
            var i=$('i')
            i.click(function(){
            $(this).parent().remove();
        })
        }
    </script>
</html>